//
//  RAPComposeMenuButton.swift
//  COPYCAT-Weibo
//
//  Created by 闫萌 on 1/4/16.
//  Copyright © 2016 RendezvousAuParadis. All rights reserved.
//

import UIKit

private let kPadding: CGFloat = 15

class RAPComposeMenuButton: UIButton {
    
    override init(frame: CGRect) {
        super.init(frame: frame)

        prepareToUse()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func prepareToUse() {
        titleLabel?.textAlignment = .Center
        contentMode = .Center
//        adjustsImageWhenHighlighted = false
    }
    
    override var highlighted: Bool {
        set {
            // 留空
        }
        get {
            return false
        }
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        let side = currentImage!.size.width
        let  centerX = CGRectGetMidX(bounds)

        imageView?.center = CGPoint(x: centerX, y: side * 0.5)

        titleLabel?.center = CGPoint(x: centerX, y: CGRectGetMaxY((imageView?.frame)!) + kPadding)
    }
}
